package com.sogeti.mentormatch.dao;

import java.io.Serializable;

/**
 * @author Matthew L. Maurer <maurer.it@gmail.com>
 */
public interface DataAccessObject<DOBJECT, PKEY extends Serializable>
{
    /**
     * Persist a Data Object in the back-end.
     * 
     * @param newInstance
     *                The Data Object to persist to the back-end.
     * @return The primary key of the instance.
     */
    public PKEY create ( DOBJECT newInstance );

    /**
     * Update a Data Object that has already been persisted to the back-end.
     * 
     * @param transientObject
     *                Persistent Data Object to persist.
     */
    public void update ( DOBJECT transientObject );

    /**
     * Delete a Data Object that has already been persisted to the back-end.
     * 
     * @param persistentObject
     *                Persistent Data Object to delete.
     */
    public void delete ( DOBJECT persistentObject );

    /**
     * Retrieve an object that was previously persisted to the database using
     * the indicated id as primary key
     */
    public DOBJECT read ( PKEY id );
}
